<template>
  <div class="home">
    <p>home</p>
  </div>
</template>

<script>

export default {
  name: "HomeView",
  async created() {
    let objMap = new Map()
    let locationMap = new Map()

    if (this.$store.getters.govRegionList.length === 0
      || Object.keys(this.$store.getters.govRegionMap).length === 0
      || this.$store.getters.locationMap.size === 0) {
      const { data: data } = await this.$http.get("/regions");
      data.forEach((element) => {
        objMap[element.id] = {
          id: element.id,
          value: element.code,
          label: element.name,
          parentId: element.parentId,
        };
        locationMap.set(element.code, element)
      });

      this.$store.state.govRegionList = data
      this.$store.state.govRegionMap = objMap
      this.$store.state.locationMap = locationMap
    }
  },
};
</script>

<style lang="scss" scoped>
</style>